package com.sky.mapper;

import com.sky.entity.Note;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface NoteMapper {
    @Select("SELECT * FROM note ORDER BY time DESC")
    List<Note> selectAll();

    @Insert("INSERT INTO note(content, time) VALUES(#{content}, #{time})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Note note);

    @Update("UPDATE note SET content=#{content}, time=#{time} WHERE id=#{id}")
    int update(Note note);

    @Delete("DELETE FROM note WHERE id=#{id}")
    int delete(Long id);

    @Select("SELECT * FROM note WHERE id=#{id}")
    Note selectById(Long id);
}
